<template>
	<view>
		<view class="bg_FFFFFF u-p-30 u-flex u-row-between">
			<view class="u-b-r-16 u-flex u-w-700" style="background-color: #F5F5F5; padding:0 20rpx ;">
				<u-image src='https://www.sqkjkj.vip/wxImg/mylick/img.png' width='27rpx' height='27rpx'></u-image>
				<view class="u-m-l-20">
					<u-input v-model="params.search" @blur="inputBlur" />
				</view>
			</view>
		</view>
		<view class="u-p-20">
			<view class="u-b-r-10 bs_CCCCCC bg_FFFFFF u-m-b-20 u-p-20" v-for="(item,index) in list " :key="index"  >
				<view class="u-text-right" @click.stop="remove(item.id)">
					<u-icon name="close-circle-fill" color="#FB473C" size="45"></u-icon>
				</view>
				<view class="u-flex">
					<view class="u-m-l-20">
						<u-image :src="item.img" mode="aspectFill" width="178rpx" height='178rpx'>
						</u-image>
					</view>
					<view @click="$u.route(`${item.goods_type==1?`/pages/home/paymassage?num=${item.spu}`:`/pages/home/shopmassage?num=${item.spu}`}`)" class=" u-p-10 u-p-l-20">
						<view class="u-weight u-font-30">{{item.name}}</view>
						<view class="u-m-t-20 u-font-35 u-weight" style="color: #FC3533;">
							<text v-if="item.is_bjg==1" class="u-font-20 cl_FFF "
								style="background: linear-gradient(-64deg, #FF5D3D, #FF7F2A);display: inline-block;padding: 4rpx;">半价购</text>
							￥{{item.price}}
						</view>
						<view class="u-m-t-30 u-font-20 " style="color: #848484;">已售{{item.sales}}件</view>

					</view>
				</view>
			</view>
			<!-- 加载更多 -->
			<u-loadmore :status="status" icon-type="circle" margin-top="20" margin-bottom="20" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num: 0,
				good_id: '',
				list: [],
				params: {
					page: 1,
					page_size: 20,
					search:''
				},
				status: 'loadmore',
			}
		},
		onLoad() {
			this.clear()
			this.massage()
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.massage();
		},
		// 获取我收藏的商品
		methods: {
			inputBlur(){
				this.clear()
				this.massage()
			},
			clear() {
				this.list = [];
				this.params.page = 1;
			},
			massage() {
				this.$api.my_lick_good(this.params, res => {
					if (res.data.code == 1) {
						if (res.data.data.data.length < 20) {
							this.status = 'nomore';
						} else {
							this.params.page = this.params.page + 1;
							this.status = 'loadmore';
						}
						this.list = this.list.concat(res.data.data.data);
						uni.stopPullDownRefresh();
					}
				})
			},
			remove(id) {
				this.$api.my_lick_good_remove({
					id
				}, res => {
					if (res.data.code == 1) {
						uni.showToast({
							icon: 'none',
							title: '删除成功'
						})
						this.clear()
						this.massage()
					} else {
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	
</style>
